<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">

  <xi:include href="tb-master.html" />

<head>
	<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
  	<title>${post.post_title}</title>
  	<meta name="description" content="${post.post_description}" />
  	<meta name="keywords" content="${', '.join([k.keyword for k in post.keywords])}" />
  	${tmpl_context.tabs()}
  	${tmpl_context.googlemaps_js()}
	<script type='text/javascript' py:if=" not post.post_address">
	$(document).ready(function() {
		$('#navtabs').tabs({});})
	</script>

  	<script type='text/javascript' py:if="post.post_address">
	google.load("maps", "2");
	  var map_var =  {
		'div':'map_canvas',
		'zoom': 10,
		'lat': ${post.post_address.google_lat},
		'lng': ${post.post_address.google_lng},
	  };
	  var map;
	  var point;

	// Call this function when the page has been loaded
	function initialize() {
	  map = new google.maps.Map2(document.getElementById(map_var['div']));
	  map.setUIToDefault();
	  var point = new google.maps.LatLng(map_var['lat'], map_var['lng']);
	  map.setCenter(point, map_var['zoom']);
	  map.addOverlay(new google.maps.Marker(point));
	  //var Wikipedia = new google.maps.Layer("org.wikipedia.it");
	  //map.addOverlay(Wikipedia);
	  //var Panoramio = new google.maps.Layer("com.panoramio.all");
	  //map.addOverlay(Panoramio);
	  map.checkResize();
		}
	//google.setOnLoadCallback(initialize);
	$(document).ready(function() {
		$('#navtabs').tabs({
	    onShow: function(event, ui) {
			if (ui.id === 'div_address') {
				initialize();
				}
			}
		});
	});
  	</script>





</head>
<body>

<div id='navtabs'>
<ul>
<li><a href='#div_post'><span>Post</span></a></li>
<li><a href='#div_details'><span>Details</span></a></li>
<li><a href='#div_address'><span>Address</span></a></li>
<li><a href='#div_photos'><span>Photos</span></a></li>
<li><a href='#div_videos'><span>Videos</span></a></li>
</ul>

<div id="div_post">
		<div id="post_content">
				<h3>${post.post_title}
				<a onclick="return create('${root_url}/post/edit/${team.team_alias}/${str(post.post_id)}', {modal: true});"
							href="" >[Edit]</a>
				</h3>

				<blockquote>
					<i py:if="post.post_description">${post.post_description}
					<a onclick="return create('${root_url}/post/edit/${team.team_alias}/${str(post.post_id)}', {modal: true});"
							href="">[Edit]</a>
					</i>
					<i py:if="not post.post_description">No description available
						<a py:if="not team.page"
							onclick="return create('${root_url}/post/edit/${team.team_alias}/${str(post.post_id)}', {modal: true});"
							href="">[Add]</a>
					</i>
				</blockquote>
				<i>
					${', '.join([k.keyword for k in post.keywords])}
					<a onclick="return create('${root_url}/keyword/add/${team.team_alias}/${str(post.post_id)}', {modal: true});"
					href="#">[Add keyword]</a>
				</i>
		</div>
		<div id="post_content" >
			<div style="width:100%; text-align: right;">
				<a href="${root_url}/post/edit_content/${team.team_alias}/${str(post.post_id)}">[Edit]</a>
			</div>
			<div id="xml_content" py:if="post.post_content">
				${XML(post.xml_content)}
			</div>
			<div py:if="not post.post_content">
				No content available
			</div>
			<div style="width:100%; text-align: right;">
				<a href="${root_url}/post/edit_content/${team.team_alias}/${str(post.post_id)}">[Edit]</a>
			</div>
		</div>
</div>

<div id="div_details">
<py:for each="detail in post.post_category.details">
		<div py:if="detail.fieldkeys" id="post_content" class="ui-corner-all">
			<p py:if="not post.ordered_values(detail.detail_id)" >
			No details available
			</p>
			<table>
				<tbody>
					<tr py:for="d in post.ordered_values(detail.detail_id)">
						<th>${d[1]}</th>
						<td>${d[2]}</td>
					</tr>
				</tbody>
			</table>
			<div style="width:100%; text-align: right;">
			<a
				onclick="return create('${root_url}/post/edit_details/${team.team_alias}/${str(post.post_id)}/${detail.detail_id}', {modal: true});">[Edit]</a>
			</div>
		</div>
</py:for>
</div>

<div id="div_address">
		<div id="post_map" class="ui-corner-all" >
			<div style="width:100%; text-align: right;">
				<a href="${root_url}/post/edit_address/${team.team_alias}/${str(post.post_id)}">[Edit]</a>
			</div>
			<h4 py:if="post.post_address">${post.post_address.google_address}</h4>
			<h4 py:if="not post.post_address">No address available</h4>
			<div id="map_canvas" style="height: 400px"></div>
		</div>
</div>

<div id="div_photos">
			<div  py:if="post.post_album" id="post_content" class="ui-corner-all">
				<form action="${root_url}/post/insert_photos/${team.team_alias}/${str(post.post_id)}" method="POST" enctype="multipart/form-data" class="P10">
		       		<fieldset >
					${tmpl_context.zeroisp_fileupload()}
		       		<script type="text/javascript" language="javascript">
								$(function(){ // wait for document to load
	 								$('#T7').MultiFile({
	  									list: '#T7-list'
	 								});
								});
					</script>

		        	<legend><strong>Add Photos</strong></legend>
		        	<p>Add photos and click on save</p>
					<input type="file" name="T7" id="T7"/>
					<input type="submit" value="save" />
					<hr />
		        	<legend id="google_address_legend">To Upload</legend>
		       		<div id="T7-list" ></div>
		       		</fieldset>
		        </form>
			   </div>
		<div id="post_content" class="ui-corner-all">
			<p py:if="not post.post_album">No album available
			<a href="${root_url}/post/insert_album/${team.team_alias}/${str(post.post_id)}">[Add]</a>
			</p>
			<div py:if="post.post_album">
				<ul>
					<li><a href="${post.post_album.feed.link[2].href}" target="_blank">Picasa</a></li>
					<li><a href="${post.post_album.feed.link[2].href}#slideshow" target="_blank">Slideshow</a></li>
				</ul>
				<div id="post_content" class="ui-corner-all" py:for="i in post.post_album.feed.entry">
					<table>
						<tr>
							<td >
								<img  id="thumbnail" class="ui-corner-all" alt="${i.media.title.text}" src="${i.media.thumbnail[0].url}" />
							</td>
							<td style="width:100%">
								<h3>${i.title.text}</h3>
								<blockquote py:if="i.summary.text">${i.summary.text}</blockquote>
								<blockquote py:if="not i.summary.text">No description available</blockquote>
								<p style="text-align:right">
								<a onclick="return create('${root_url}/post/edit_photo/${team.team_alias}/${str(post.post_id)}/${i.gphoto_id.text}', {modal: true});"
								href="">[Edit]</a>
								</p>
							</td>
						</tr>
					</table>

				</div>
			</div>
		</div>

</div>

<div id="div_videos">
</div>

</div>

<!--
<table>
<tbody>
<tr >
	<td style="width:60%" >
		<h4><a href="${root_url}/team/index/${team.team_alias}">${team.team_alias}</a></h4>
		<div id="post_content">
				<h3>${post.post_title}
				<a onclick="return create('${root_url}/post/edit/${team.team_alias}/${str(post.post_id)}', {modal: true});"
							href="" >[Edit]</a>
				</h3>

				<blockquote>
					<i py:if="post.post_description">${post.post_description}
					<a onclick="return create('${root_url}/post/edit/${team.team_alias}/${str(post.post_id)}', {modal: true});"
							href="">[Edit]</a>
					</i>
					<i py:if="not post.post_description">No description available
						<a py:if="not team.page"
							onclick="return create('${root_url}/post/edit/${team.team_alias}/${str(post.post_id)}', {modal: true});"
							href="">[Add]</a>
					</i>
				</blockquote>
				<i>
					${', '.join([k.keyword for k in post.keywords])}
					<a onclick="return create('${root_url}/keyword/add/${team.team_alias}/${str(post.post_id)}', {modal: true});"
					href="#">[Add keyword]</a>
				</i>
		</div>
		<py:for each="detail in post.post_category.details">
		<div py:if="detail.fieldkeys" id="post_content" class="ui-corner-all">
			<p py:if="not post.ordered_values(detail.detail_id)" >
			No details available
			</p>
			<table>
				<tbody>
					<tr py:for="d in post.ordered_values(detail.detail_id)">
						<th>${d[1]}</th>
						<td>${d[2]}</td>
					</tr>
				</tbody>
			</table>
			<div style="width:100%; text-align: right;">
			<a
				onclick="return create('${root_url}/post/edit_details/${team.team_alias}/${str(post.post_id)}/${detail.detail_id}', {modal: true});">[Edit]</a>
			</div>
                </div>
                </py:for>

		<div id="post_content" >
			<div style="width:100%; text-align: right;">
				<a href="${root_url}/post/edit_content/${team.team_alias}/${str(post.post_id)}">[Edit]</a>
			</div>
			<div id="xml_content" py:if="post.post_content">
				${XML(post.xml_content)}
			</div>
			<div py:if="not post.post_content">
				No content available
			</div>
			<div style="width:100%; text-align: right;">
				<a href="${root_url}/post/edit_content/${team.team_alias}/${str(post.post_id)}">[Edit]</a>
			</div>
		</div>
		<div id="post_content" class="ui-corner-all">
			<p py:if="not post.post_album">No album available
			<a href="${root_url}/post/insert_album/${team.team_alias}/${str(post.post_id)}">[Add]</a>
			</p>
			<div py:if="post.post_album">
			<ul>
				<li><a href="${post.post_album.feed.link[2].href}" target="_blank">Picasa</a></li>
				<li><a href="${post.post_album.feed.link[2].href}#slideshow" target="_blank">Slideshow</a></li>
			</ul>
			<div id="post_content" class="ui-corner-all" py:for="i in post.post_album.feed.entry">
				<table>
					<tr>
						<td >
							<img  id="thumbnail" class="ui-corner-all" alt="${i.media.title.text}" src="${i.media.thumbnail[0].url}" />
						</td>
						<td style="width:100%">
							<h3>${i.title.text}</h3>
							<blockquote py:if="i.summary.text">${i.summary.text}</blockquote>
							<blockquote py:if="not i.summary.text">No description available</blockquote>
							<p style="text-align:right">
							<a onclick="return create('${root_url}/post/edit_photo/${team.team_alias}/${str(post.post_id)}/${i.gphoto_id.text}', {modal: true});"
							href="">[Edit]</a>
							</p>
						</td>
					</tr>
				</table>

			</div>
		</div>


		</div>
	</td>
	<td style="width:40%">
		<div id="post_content" class="ui-corner-all" >
		<ul py:if="post.childs">
			<li py:for="child in post.childs">
				<div><a href="${root_url}/post/index/${team.team_alias}/${child.post_id}">${child.post_title}</a></div>
				<i class="small">${child.post_description}</i>
			</li>
		</ul>
		</div>
		<div id="post_map" class="ui-corner-all" >
			<div style="width:100%; text-align: right;">
				<a href="${root_url}/post/edit_address/${team.team_alias}/${str(post.post_id)}">[Edit]</a>
			</div>
			<h4 py:if="post.post_address">${post.post_address.google_address}</h4>
			<h4 py:if="not post.post_address">No address available</h4>
			<div py:if="post.post_address" id="map_canvas" style="width: 400px; height: 320px"></div>
		</div>

			<div  py:if="post.post_album" id="post_content" class="ui-corner-all">
				<form action="${root_url}/post/insert_photos/${team.team_alias}/${str(post.post_id)}" method="POST" enctype="multipart/form-data" class="P10">
		       		<fieldset >
					${tmpl_context.zeroisp_fileupload()}
		       		<script type="text/javascript" language="javascript">
								$(function(){ // wait for document to load
	 								$('#T7').MultiFile({
	  									list: '#T7-list'
	 								});
								});
					</script>

		        	<legend><strong>Add Photos</strong></legend>
		        	<p>Add photos and click on save</p>
					<input type="file" name="T7" id="T7"/>
					<input type="submit" value="save" />
					<hr />
		        	<legend id="google_address_legend">To Upload</legend>
		       		<div id="T7-list" ></div>
		       		</fieldset>
		        </form>
			   </div>

	</td>
</tr>
</tbody>
</table>
<py:if test="debug">
	<div id="post_content" class="ui-corner-all" >
	<h1> debug </h1>
	<h2>Post</h2>
	<table>
		<tbody>
			<tr py:for="item in post._sa_class_manager.mapper.columns.keys()">
				<th>{${item}}</th>
				<td>${getattr(post, item)}</td>
			</tr>
		</tbody>
	</table>
	<hr />
	<h2>Keywords</h2>
	<div py:for="keyword in post.keywords">
	<br />
	<h4>Keyword ${keyword.keyword_id}</h4>
	<table >
		<tbody>
			<tr py:for="item in keyword._sa_class_manager.mapper.columns.keys()">
				<th>{${item}}</th>
				<td>${getattr(keyword, item)}</td>
			</tr>
		</tbody>
	</table>
	</div>
	<hr />
	<h2>Address</h2>
	<table>
		<tbody>
			<tr py:for="item in post.post_address._sa_class_manager.mapper.columns.keys()">
				<th>{${item}}</th>
				<td>${getattr(post.post_address, item)}</td>
			</tr>
		</tbody>
	</table>
	<hr />
	<h2>Details</h2>
	<table>
		<tbody>
			<tr py:for="d in post.ordered_values">
				<th>${d[0]}</th>
				<th>${d[1]}</th>
				<td>${d[2]}</td>
			</tr>
		</tbody>
	</table>
	<hr />
	<h2>Team</h2>
	<table>
		<tbody>
			<tr py:for="item in team._sa_class_manager.mapper.columns.keys()">
				<th>{${item}}</th>
				<td>${getattr(team, item)}</td>
			</tr>
		</tbody>
	</table>
	</div>

</py:if>

 -->

<script type="text/javascript">
var allDialogs = [];
function create(href, options) {
options = $.extend({title: "Dialog"}, options || {});
var dialog = new Boxy.load(href, options); /*new Boxy(content, options);*/
allDialogs.push(dialog);
return false;
}
</script>


</body>
</html>
